<?php

namespace admin\dao;

/**--tmpl-use--**/
use herosphp\core\Loader;

/**--tmpl-import--**/

class NavDao extends CommonDao{

	/**--tmpl-vars--**/
	
	/**--tmpl-construct--**/

	/**--tmpl-method--**/
	/**-- daoGetItems --**/
	public function getItems($conditions, $fields, $order, $limit, $group, $having)
	{
		$items = parent::getItems($conditions, $fields, $order, $limit, $group, $having);
		if(!$items) return NULL;
	
		/**--tmpl-todo--**/
	
		/**-- foreigncondi --**/
		$manager_managercondi = array();
		
		foreach($items as $k => $v)
		{
			if($v['manager_id'])
			{
				$manager_managercondi[] = $v['manager_id'];
			}
		}
		
		$adminDao = Loader::model('adminManager');
		$manager = $adminDao->getItems(array('id' => array('$in' => $manager_managercondi)));
		$typemap = array (
		  0 => '文字',
		  1 => '图片',
		);
		/**-- foreignforeach  --**/
		foreach ($items as $k => $v)
		{
			/**--tmpl-foreignfill--**/
		
			foreach($manager as $kk => $vv)
			{
				if($vv['id'] == $v['manager_id'])
				{
					$items[$k]['manager_name'] = $vv['name'];
				}
			}
			
			$items[$k]['type_text'] = $typemap[$v['type']];
			
		}
		
	
	
		return $items;
	}

}
